<!doctype html>
<html lang="en">

<head>
	<title>鑫洋泉运营管理平台</title>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<!-- VENDOR CSS -->
	<link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="../assets/vendor/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../assets/vendor/dataTables/jquery.dataTables.min.css">
	<link rel="stylesheet" href="../assets/vendor/linearicons/style.css">
	<!-- MAIN CSS -->
	<link rel="stylesheet" href="../assets/css/main.css">
	<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
	<link rel="stylesheet" href="../assets/css/demo.css">
	<!-- GOOGLE FONTS -->
	<!--<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet">-->
	<!-- ICONS -->
	<link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png">
	<link rel="icon" type="image/png" sizes="96x96" href="../assets/img/favicon.png">
</head>

<body>
	<!-- WRAPPER -->
	<div id="wrapper">
		<!-- NAVBAR -->
		<nav class="navbar navbar-default navbar-fixed-top">
			<h1 class="header_1">
				 鑫洋泉运营管理系统 
			</h1>
		</nav>


		<!-- END NAVBAR -->
		<!-- LEFT SIDEBAR -->
		<div id="sidebar-nav" class="sidebar">
			<div class="sidebar-scroll">
				<nav>
					<ul class="nav">
                        <li><a href="index.html" class="active"><i class="lnr lnr-home"></i> <span>首页</span></a></li>
                        <li><a href="device.html" class=""><i class="lnr lnr-chart-bars"></i> <span>车辆信息</span></a></li>
                        <li><a href="custom.html" class=""><i class="lnr lnr-chart-bars"></i> <span>客户信息</span></a></li>
                         
                        <li>
                            <a href="#"><i class="lnr lnr-chart-bars"></i> <span>SIM卡管理</span></a>
                            <ul class="nav">
                                <li><a href="cardsStatistics.html">统计信息</a></li>
                                <li><a href="cardsList.html">列表信息</a></li>
                            </ul>
                        </li>
                        <li>
							<a href="config.html"><i class="lnr lnr-chart-bars"></i> <span>配置管理</span></a>
							<ul class="nav">
								<li><a href="config.html" class=""><span>默认配置列表</span></a></li>
								<li><a href="parameters.html?1" class=""><span>解码类型</span></a></li>
								<li><a href="parameters.html?2" class=""><span>主机盒界面</span></a></li>
								<li><a href="parameters.html?3" class=""><span>前景和前后视角</span></a></li>
								<li><a href="parameters.html?4" class=""><span>转向视角</span></a></li>
								<li><a href="parameters.html?5" class=""><span>轨迹线类型</span></a></li>
						
							</ul>
						</li><!--<li><a href="device_detail.html" class=""><i class="lnr lnr-cog"></i> <span>设备详情</span></a></li>-->
                    </ul>
				</nav>
			</div>
		</div>
		<!-- END LEFT SIDEBAR -->
		<!-- MAIN -->
		<div class="main">
			<!-- MAIN CONTENT -->
			<div class="main-content">
				<div class="container-fluid">
                    <div class="row">
                        <div class="col-md-7">
					            <h3 class="page-title ">SIM列表信息</h3>
                        </div>
                        <div class="col-md-4">
                            <form class="navbar-form navbar-right">
                                <div class="input-group">
                                    <input type="text" value="" id="sim_id" class="form-control" placeholder="卡号">
                                    <span class="input-group-btn"><button type="button" onClick="search()" class="btn btn-primary">查询</button></span>
                                </div>
                            </form> 
                        </div>
                        <div class="col-md-1">
                            <form class="navbar-form navbar-right">
                                <div class="input-group">
                                    <span class="input-group-btn"><button type="button" onClick="showModal()" class="btn btn-primary">导入</button></span>
                                </div>
                            </form> 
                        </div>
                    </div>

                    <div class="row">
                        <table id="example" class="col-md-12 display" cellspacing="0" width="2000px">
                            
                            <!--<tfoot>
                                <tr>
                                    <th>Name</th>
                                    <th>Position</th>
                                    <th>Office</th>
                                    <th>Extn.</th>
                                    <th>Start date</th>
                                    <th>Salary</th>
                                </tr>
                            </tfoot>-->
                        </table>
					</div>
				</div>
			</div>
			<!-- END MAIN CONTENT -->
		</div>

        <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div class="modal-body">
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label for="user_id" class="col-sm-3 control-label">iccid</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="iccid" name="mobile" value=""
                                        placeholder="">
                                </div>
                            </div>
                        </form>
                    </div>
                    <div id="tip"></div>
                    <div class="modal-footer">
                        
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" onClick="addIccid()">提交</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div>
		<!-- END MAIN -->
		<div class="clearfix"></div>
		<footer>
			<div class="container-fluid">
			</div>
		</footer>
	</div>
	<!-- END WRAPPER -->
	<!-- Javascript -->
	<script src="../assets/vendor/jquery/jquery.min.js"></script>
	<script src="../assets/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script src="../assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <script src="../assets/vendor/dataTables/jquery.dataTables.min.js"></script>
	<script src="../assets/scripts/klorofil-common.js"></script>
    <script>
    var basePath = '/oss-ws/ws/0.1/';
    </script>
    <script>
    var showModal = function () {
        $('#iccid').val('');
        $('#addModal').modal('show');
    }

    var addGPRS = function(iccid) {
        var data={}, url;
        data.iccid = iccid;
        url= basePath + 'simInfo/GPRS';
        doAjax(data, url);
    }
    var addCarStatus = function(iccid) {
        var data={}, url;
        data.iccid = iccid;
        url= basePath + 'simInfo/CarStatus';
        doAjax(data, url);
    }

    var addIccid = function(){
        var data={}, url;
        data.iccid = $('#iccid').val().trim();
        if(data.iccid){
            url = basePath + 'simInfo/add';
        } else {
            alert('请输入iccid');
            return;
        }
        doAjax(data, url);

    }
    var doAjax = function(data, url) {
        $.ajax({
            url: url,
            // url: "../ws/0.1/vehicle",
            // data: data,
            type: "post",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(data),
            dataType: "json",
            beforeSend:function()
            {
                $("#tip").html("<span style='color:blue'>正在处理...</span>");
                return true;
            },
            success:function(data)
            {
        // "url": "../ws/0.1/vehicle/datas",
                if(data.code == 200)
                {
                    table.ajax.url(basePath+"simInfo/datas").load();
                    // $("#successMessage").html("修改成功");
                    $("#tip").html("<span style='color:blue'>导入成功</span>");
                    window.location.reload();

                    // table.ajax.url('../ws/0.1/vehicle/datas').load();
                }
                else
                {
                    // $("#warningMessage").html(data.message);
                    hideModal();
                    alert(data.message);
                }
                // $('#myModal').modal('hide');
            },
            error: function()
            {
                alert('请求出错');
            },
            complete: function()
            {
                // $('#acting_tips').hide();
            }
        });
    }
    var table = $('#example').DataTable( {
        oLanguage: {
            "sUrl": "../assets/vendor/dataTables/zh_CN.json"
        },
        "scrollX": true,
        //左下角信息
        info: false,
        //关闭行数选择
        "lengthChange": false,
        //关闭本地搜索
        "searching": false,
        //关系列排
      
         //"serverSide": true,//分页，取数据等等的都放到服务端去
           //"deferRender": true,//当处理大数据时，延迟渲染数据，有效提高Datatables处理能力
            "destory": true,
            "ajax": {
                "dataType": 'json',
                "type": "get",
                "url": basePath+"simInfo/datas",
                "data": function (d) {
                    // d.id = id;
                },
                "async": false
            },
            "columns": [
                {
                    "data": "userCode",
                    "title": '卡号'
                }, {
                    "data": "iccid",
                    "title": "iccid"
                }, {
                    "width": 40,
                    "data": "carStatus",
                    "title": "卡状态"
                /*}, {
                    "width": 40,
                    "data": "operator",
                    "title": "运营商"*/
                }, {
                    "width": 40,
                    "data": "flowOnline",
                    "title": "GPRS功能"
                }, {
                    "width": 40,
                    "data": "switchStatus",
                    "title": "设备状态"
                }, {
                    "width": 40,
                    "data": "GPRS",
                    "title": "GPRS状态"
                }, {
                    "width": 80,
                    "data": "userAff",
                    "title": "归属客户"
                }, {
                    "width": 40,
                    "data": "combo",
                    "title": "套餐类型"
                }, {
                    "width": 50,
                    "data": "flowSum",
                    "title": "流量总量(M)"
                }, {
                    "width": 50,
                    "data": "flowMoney",
                    "title": "流量花费(M)"
                }, {
					"data": "iccid",
                    "title": "操作",
                    "width": 230,
					render: function (data) {
                        return "<a href='device_detail.html?iccid="  
                            + data 
                            + "?simInfo?vehicles'>车关系 </a><a href='chargeRecord.html?iccid="  
                            + data 
                            + "'>充值记录 </a><a href='cardsDetail.html?iccid="  
                            + data 
                            + "'>卡消耗</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='cardsDayMon.html?iccid="  
                            + data 
                            + "'>卡统计</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onClick='addGPRS("
                            + JSON.stringify(data)
                            + ")'>暂停/恢复GPRS</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onClick='addCarStatus("
                            + JSON.stringify(data)
                            +")'>停机/复机</a>"
                            ;
                    }
				}
            ]

        // "ajax": '../assets/device_ajax.txt'
    } );

    function search() {
        var id = $('#sim_id').val().trim();
        if(id != '') {
            // table.ajax.url('../ws/0.1/simInfo/data?iccid=' + id.value).load()
            table.ajax.url(basePath+'simInfo/data?iccid=' + id.value).load()
        }else {
            // table.ajax.url('../ws/0.1/simInfo/datas').load()
            table.ajax.url(basePath+'simInfo/datas').load()
		}
    }
    </script>
</body>

</html>
